//
//  YCSellerInfoTableViewCell.m
//  YCVillageDoctor
//
//  Created by zhangxiaoliang on 2017/7/10.
//  Copyright © 2017年 zhangxiaoliang. All rights reserved.
//

#import "YCSellerInfoTableViewCell.h"
#import "YCSellerInfoModel.h"
@interface YCSellerInfoTableViewCell ()

@property(nonatomic,strong)UILabel *timeLabel;
@property(nonatomic,strong)UILabel *phoneLabel;
@property(nonatomic,strong)UILabel *nameLabel;

@end
@implementation YCSellerInfoTableViewCell

- (void)setModel:(YCSellerInfoModel *)model
{
    _model = model;
    if (model.LINK_MOBILE.length >= 11) {
           self.phoneLabel.text = [model.LINK_MOBILE stringByReplacingCharactersInRange:NSMakeRange(3, 4) withString:@"****"];
    }
    self.nameLabel.text = model.USER_NAME;
    self.timeLabel.text = [model.CREATE_DATE substringToIndex:10];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        UILabel *nameLabel = [[UILabel alloc]init];
        self.nameLabel = nameLabel;
        nameLabel.font = [UIFont systemFontOfSize:14];
        nameLabel.textColor = RGB(152, 152, 152);
        [self.contentView addSubview:nameLabel];
        
        UILabel *phoneLabel = [[UILabel alloc]init];
        self.phoneLabel = phoneLabel;
        phoneLabel.font = [UIFont systemFontOfSize:14];
        phoneLabel.textColor = RGB(152, 152, 152);
        phoneLabel.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:phoneLabel];
        
        UILabel *timeLabel = [[UILabel alloc]init];
        self.timeLabel = timeLabel;
        timeLabel.font = [UIFont systemFontOfSize:14];
        timeLabel.textColor = RGB(152, 152, 152);
        timeLabel.textAlignment = NSTextAlignmentRight;
        [self.contentView addSubview:timeLabel];
        
        __weak __typeof(&*self)mySelf = self;
        
        [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.top.mas_equalTo(mySelf.contentView.mas_top).mas_offset(0);
            make.left.mas_equalTo(mySelf.contentView.mas_left).mas_offset(10);
            make.width.mas_equalTo(120);
            make.height.mas_equalTo(mySelf.contentView);
        }];
        
        [phoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.top.mas_equalTo(nameLabel).mas_offset(0);
            make.left.mas_equalTo(nameLabel.mas_right).mas_offset(10);
            make.width.mas_equalTo(100);
            make.height.mas_equalTo(mySelf.contentView);
        }];
        [timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.top.mas_equalTo(nameLabel).mas_offset(0);
            make.left.mas_equalTo(phoneLabel.mas_right).mas_offset(10);
            make.height.mas_equalTo(mySelf.contentView);
            make.right.mas_equalTo(mySelf.contentView.mas_right).mas_offset(-10);
        }];
    }
    return self;
}
@end
